/*
 * Screen
 *
 */

#include "Screen.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

/*
typedef struct
{
	int 	H;
	int	W;
	float 	distance;
	float	fov;
	float	h;
	float	w;
	unsigned char * map;
} Screen_t;
*/

void Create_Screen(Screen_t * screen, int p_H, int p_W, float p_d, float p_fov_h, float p_fov_w)
{

	screen->H 	= p_H;
	screen->W 	= p_W;
	screen->distance= p_d;
	screen->fov_H	= p_fov_h;
	screen->fov_W	= p_fov_w;
	screen->h	= 2*p_d*tan(p_fov_h*(M_PI/180.0));
	screen->w	= 2*p_d*tan(p_fov_w*(M_PI/180.0));
	screen->map	= (unsigned char *) malloc(4*p_H*p_W*sizeof(unsigned char));

	fprintf(stdout, "Screen (%d,%d)\nDistance %f fov(%f,%f)\nTamaño pantalla en mundo (%f,%f)\n",p_H,p_W,p_d,p_fov_h,p_fov_w,screen->h,screen->w);

}

void Destroy_Screen(Screen_t screen)
{
	free(screen.map);
}
